// ajax统一发送请求，统一管理
// 1. ajax
import ajax from './ajax' 
import mockAjax from './mockAjax'
// 2. 发送请求 获取三级分类列表的数据
export const reqCategoryListData = () => ajax.get('/product/getBaseCategoryList')

// 3. 获取轮播图时的接口函数
export const reqGetBannerListData = () => mockAjax.get('/bannerList')

// 4.获取楼层数据
export const reqGetFloorsListData = () => mockAjax.get('/floorsList')

// 5.获取search页面数据
export const reqPostSearchGoodsInfoData = searchParams => ajax.post('/list',searchParams)

// 获取商品详情数据
export const reqGetGoodsDetailInfoData = skuId => ajax.get(`/item/${skuId}`)

// 添加商品到购物车
export const reqPostAddOrUpdateSkuInfoToShopCart = (skuId,skuNum) =>ajax.post(`/cart/addToCart/${skuId}/${skuNum}`)

// 购物车列表
export const reqGetShopCartListData = () => ajax.get('/cart/cartList')

// 更新购物车数据
export const reqGetChangeCartListData = (skuID,isChecked) => ajax.get(`/cart/checkCart/${skuID}/${isChecked}`)

// 批量更新购物车中的商品选中状态
// export const reqPostChangeAllShopCartInfoState = (isChecked,skuIdList) =>ajax.post(`/cart/batchCheckCart/${isChecked}`,skuIdList)
export const reqPostChangeAllShopCartInfoState = (isChecked,skuIdList) =>ajax({
  url:`/cart/batchCheckCart/${isChecked}`,
  method:'post',
  data:skuIdList
})

// 删除一件购物车的商品
// export const reqDelOneShopCartInfo = (skuId) => ajax({
//   url:`/cart/deleteCart/${skuId}`,
//   method:'delete',
//   // data:skuId
// })
export const reqDelOneShopCartInfo = (skuId) => ajax.delete(`/cart/deleteCart/${skuId}`)

// 批量删除选中的商品
export const reqDelAllShopCartInfo = (skuIdList) => ajax({
  url:`/cart/batchDeleteCart`,
  method:'post',
  data:skuIdList
})

// 获取手机验证码
export const reqGetPhoneVerifyCode = phone => ajax.get(`/user/passport/sendCode/${phone}`)

// 注册请求
export const reqPostRegister = (user) => ajax.post(`/user/passport/register`,user)

//登录接口
export const reqPostUserLogin = (user) => ajax.post(`/user/passport/login`,user)

// 退出登录接口
export const reqGetLogout = () => ajax.get(`/user/passport/logout`)

// 获取订单交易页数据
export const reqGetTradeData = () => ajax.get('/order/auth/trade')

// 获取用户地址
export const reqGetUserAddressList = () => ajax.get('/user/userAddress/auth/findUserAddressList')

// 提交订单
export const reqPostSubmitTradeOrder = (tradeNo,params) => ajax.post(`/order/auth/submitOrder?tradeNo=${tradeNo}`,params)

// 获取订单支付信息 支付二维码
export const reqGetPayQrCode = (orderId) => ajax.get(`/payment/weixin/createNative/${orderId}`)

// 查看订单支付状态
export const reqGetQueryPayStatus = (orderId) => ajax.get(`payment/weixin/queryPayStatus/${orderId}`)

// 获取订单列表，center查看订单中心
export const reqGetCenterListData = (page,limit) => ajax.get(`/order/auth/${page}/${limit}`)